algalcommand.io
Class AlgalNetIO

java.lang.Object
  extended by algalcommand.io.AlgalNetIO

public class AlgalNetIO
extends java.lang.Object

Copyright Owner: Michigan State University, license number TEC2011-002101Prov


Field Summary
static java.lang.String COMMAND_PREFIX
          This is the prefix that the PBRBrain uses to differentiate commands from other stuff that it receives from its serial input
static java.lang.String COMMAND_SUFFIX
          The suffix is used by the PBRBrain to know when to parse the input command (actually, the PBRBrain is usually smart enough to not need this, but that behavior is not a design spec., so that may not always be true).
static java.lang.String PING_COMMAND
          This is the ping command
static java.lang.String PING_RESPONCE_TAGNAME
          Name of the XML tag that is sent back in responce to a ping
 
Constructor Summary
AlgalNetIO()
           
 
Method Summary
 byte[] connectToAddress(java.lang.String networkAddress)
          Connects to the given IP address (tries to, anyway).
 byte[] getMAC()
           
 boolean sendCommand(java.lang.String text)
          Sends a command to the PBRBrain over the network
 void startListening()
           
 void stopListening()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMMAND_PREFIX

public static final java.lang.String COMMAND_PREFIX
This is the prefix that the PBRBrain uses to differentiate commands from other stuff that it receives from its serial input

See Also:
Constant Field Values

COMMAND_SUFFIX

public static final java.lang.String COMMAND_SUFFIX
The suffix is used by the PBRBrain to know when to parse the input command (actually, the PBRBrain is usually smart enough to not need this, but that behavior is not a design spec., so that may not always be true).

See Also:
Constant Field Values

PING_COMMAND

public static final java.lang.String PING_COMMAND
This is the ping command

See Also:
Constant Field Values

PING_RESPONCE_TAGNAME

public static final java.lang.String PING_RESPONCE_TAGNAME
Name of the XML tag that is sent back in responce to a ping

See Also:
Constant Field Values
Constructor Detail

AlgalNetIO

public AlgalNetIO()
Method Detail

connectToAddress

public byte[] connectToAddress(java.lang.String networkAddress)
                        throws java.net.SocketException,
                               java.io.IOException
Connects to the given IP address (tries to, anyway).

Parameters:
networkAddress -
Returns:
The Hardware (MAC) address of the host at the given IP address, in the form of a byte array.
Throws:
java.net.SocketException - Thrown if the socket could not be created.
java.io.IOException - Thrown if the socket could not be used.

getMAC

public byte[] getMAC()
Returns:
The Hardware address of the socket's host (aka the MAC of the PBR embedded ethernet module).

sendCommand

public boolean sendCommand(java.lang.String text)
Sends a command to the PBRBrain over the network

Parameters:
text - The command to send
Returns:
true if the command was sent successfully, false otherwise.

startListening

public void startListening()
                    throws java.io.IOException
Throws:
java.io.IOException

stopListening

public void stopListening()